﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterpage_user.master" AutoEventWireup="true"
    CodeFile="QLTinNhan.aspx.cs" Inherits="QLTinNhan" %>
<asp:Content ID="Content1" ContentPlaceHolderID="user_content" runat="Server">
<script src="./javascripts/t_js.js"></script>
    <div id="quanlysanpham">
    <div class="title">Quản Lý Tin Nhắn</div>

    <div class="rowFeature">
        <div class="featureDeleteSelect"><asp:Button ID="btXoaChon" runat="server" onclick="btXoaChon_Click" 
            Text="Xóa" OnClientClick="return DeleteConfirmation();" /></div>
        <div class="featureSearch"><asp:TextBox ID="txtKeyword" runat="server" 
                Enabled="False"></asp:TextBox>&nbsp;&nbsp;
        <asp:Button ID="btTimKiem" runat="server" onclick="btTimKiem_Click" Text="Tìm kiếm" 
                Enabled="False" /></div>
    </div>

    <div class="messageError">
        <asp:Label ID="lblError" runat="server" Font-Bold="False" Font-Names="Arial" 
            Font-Size="X-Large" ForeColor="#CC0000" Visible="False"></asp:Label></div>
    
    <div class="scrollGridView">
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataKeyNames="Matinnhan" DataSourceID="SqlDataSource1" Font-Names="Arial" Font-Overline="False"
        Font-Size="Medium" Font-Strikeout="False" 
            AllowPaging="True" AllowSorting="True" EmptyDataText="(Không tìm thấy dữ liệu!)"
        OnSelectedIndexChanged="GridView1_SelectedIndexChanged" 
            HorizontalAlign="Center" CssClass="table-a">
        <Columns>
            <asp:TemplateField>
                <EditItemTemplate>
                    <asp:CheckBox ID="chkItem" runat="server" Enabled="False" />
                </EditItemTemplate>
                <HeaderTemplate>
                    <asp:CheckBox ID="chkHeader" runat="server" AutoPostBack="true" OnCheckedChanged="chkHeader_CheckedChanged" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox ID="chkItem" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Mã Tin Nhắn" SortExpression="Matinnhan">
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Matinnhan") %>'></asp:Label>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Matinnhan") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Username" SortExpression="Username">
                <EditItemTemplate>
                    <asp:DropDownList ID="DropDownList3" runat="server" 
                        DataSourceID="SqlDataSource2" DataTextField="Hoten" DataValueField="Username" 
                        SelectedValue='<%# Bind("Username") %>'>
                    </asp:DropDownList>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text=''></asp:Label>
                    <itemtemplate>
                        <%# HighlightText(txtKeyword.Text, Eval("Username").ToString())%>
                    </itemtemplate>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tiêu Đề" SortExpression="Tieude">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Tieude") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Tieude") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Người Nhận" SortExpression="Nguoinhan">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Nguoinhan") %>'></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("Nguoinhan") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Ngày Gửi" SortExpression="Ngaygoi">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Ngaygoi") %>' 
                        Height="21px"></asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("Ngaygoi") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False">
                <EditItemTemplate>
                    <asp:Button ID="Button1" runat="server" CausesValidation="True" 
                        CommandName="Update" Text="Cập nhật" />
                    &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="Hủy" />
                </EditItemTemplate>
                <ItemTemplate>
                    <input type="button" onclick="location.href='editQLTinNhan.aspx?MaTN=<%#Eval("Matinnhan")%>'" value="Sửa" />
                    &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" OnClientClick="return DeleteConfirmation();"
                        CommandName="Delete" Text="Xóa" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
            <EmptyDataRowStyle Font-Size="X-Large" ForeColor="#CC0000" 
                HorizontalAlign="Center" />
        <FooterStyle 
                HorizontalAlign="Center" />
        <HeaderStyle Font-Underline="True"
            Height="30px" HorizontalAlign="Center" VerticalAlign="Middle" />
        <PagerSettings PageButtonCount="7" />
        <PagerStyle CssClass="page" Font-Names="Arial" 
                Font-Size="Large" 
                VerticalAlign="Middle" />
        <RowStyle HorizontalAlign="Center" />
    </asp:GridView>
    </div>
    </div>

        <asp:Label ID="Label5" runat="server" Text="Label" Visible="False"></asp:Label>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:chodientuConnectionString %>"
        
        SelectCommand="sp_DSTinNhan" OldValuesParameterFormatString="original_{0}"
        DeleteCommand="DELETE FROM [Tinnhan] WHERE [Matinnhan] = @original_Matinnhan"
        
        
        
        
        
        UpdateCommand="UPDATE Tinnhan SET Username = @Username, Tieude = @Tieude, Nguoinhan = @Nguoinhan, Ngaygoi = @Ngaygoi, Noidungtinnhan = @Noidungtinnhan WHERE (Matinnhan = @original_Matinnhan)" 
        SelectCommandType="StoredProcedure">
        <DeleteParameters>
            <asp:Parameter Name="original_Matinnhan" Type="String" />
        </DeleteParameters>
        <SelectParameters>
            <asp:SessionParameter ConvertEmptyStringToNull="False" Name="User" 
                SessionField="User" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Username" />
            <asp:Parameter Name="Tieude" />
            <asp:Parameter Name="Nguoinhan" />
            <asp:Parameter Name="Ngaygoi" />
            <asp:Parameter Name="Noidungtinnhan" />
            <asp:Parameter Name="original_Matinnhan" />
        </UpdateParameters>
    </asp:SqlDataSource>
    </asp:Content>
